<html>
<!-- 
  Copyright 2010 Scott Logic Ltd.
  http://www.scottlogic.co.uk
  
  This file is part of Closure Charts.

  Closure Charts is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  Closure Charts is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with Closure Charts.  If not, see <http://www.gnu.org/licenses/>.
-->
<head>
<title>JavaScript Charting Unit Tests - Style</title>
<script type="text/javascript" src="../../../../../../../../closure-library/src/main/webapp/js/goog/base.js"></script>
<script type="text/javascript" src="../unitTestDependencies.js"></script>
<script>
    goog.require('goog.testing.jsunit');
    goog.require('goog.dom');
    
    goog.require('scottlogic.chart.rendering.Style');
</script>
</head>
<body>
<script>  
    // Clear the canvas after the charts have been tested
    function tearDown(){
        var canvas = goog.dom.$('canvas');
        canvas.innerHTML = '';
    }
    
    function testParent() {
    	var parent = new scottlogic.chart.rendering.Style(null, null, null, "#444");
    	
    	var stroke = new goog.graphics.Stroke(1, "#3F3");
    	var defaultStroke = new goog.graphics.Stroke(1, "#000000");
    	var child = new scottlogic.chart.rendering.Style(parent, stroke, null, null);
    	
    	assertEquals("Child inherits parents font colour", child.getFontColour(), "#444");
    	assertEquals("Childs stroke overwrites parents", child.getStroke().getColor(), "#3F3");
    	assertEquals("Parent has default values", parent.getStroke().getColor(), "#000000");
    }
    
    function testMerge() {
    	var style = new scottlogic.chart.rendering.Style(null, null, null, null);
    	var merger = new scottlogic.chart.rendering.Style(null, null, null, "blue");
    	
    	style.merge(merger);
    	assertEquals("Overwrite", style.getFontColour(), "blue");
    	assertEquals("Defaults still exist", style.getFont().size, 13);
    	
		var parent = new scottlogic.chart.rendering.Style(null, null, null, "red");
    	
    	var stroke = new goog.graphics.Stroke(1, "green");
    	var defaultStroke = new goog.graphics.Stroke(1, "black");
    	var child = new scottlogic.chart.rendering.Style(parent, stroke, null, null);
    	
    	child.merge(merger);
    	
    	assertEquals("Child has merged", child.getFontColour(), "blue");
    	assertEquals("Parent has not merged", parent.getFontColour(), "red");
    }
   
</script>
<div id="canvas"></div>
</body>
</html>
